package com.example.portlocalforward.entity;

import java.time.LocalDateTime;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * SSH隧道实体类
 * 
 * @author Generated
 * @version 1.0.0
 */
@Entity
@Table(name = "ssh_tunnel")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SshTunnel {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    @Column(name = "name", nullable = false, length = 100)
    private String name; // 隧道名称
    
    @Column(name = "host", nullable = false, length = 255)
    private String host; // 隧道地址
    
    @Column(name = "port", nullable = false)
    private int port; // 端口
    
    @Column(name = "username", nullable = false, length = 100)
    private String username; // 用户名
    
    @Column(name = "password", nullable = false, length = 255)
    private String password; // 密码
    
    @Column(name = "created_time", nullable = false)
    private LocalDateTime createdTime; // 创建时间
    
    @Column(name = "updated_time")
    private LocalDateTime updatedTime; // 更新时间
    
    @PrePersist
    protected void onCreate() {
        createdTime = LocalDateTime.now();
        updatedTime = LocalDateTime.now();
    }
    
    @PreUpdate
    protected void onUpdate() {
        updatedTime = LocalDateTime.now();
    }
}
